﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<head>
<title>新增产品</title>
<style>
.form-control {
	width: 70%;
}
</style>
<script type="text/javascript">
	$(function(){
		$("#productName").blur(function(){
			var productName = $("#productName").val();
			if(productName == null || productName == ''){
				alert("产品名称不能为空");
				return;
			} 
			$.post("${basePath}/product/isProductNameUniq",{productName:productName},function(data){
				if(data.code!=200){
					//$("#productName").val("");
					//$("#productName").focus();
					alert("产品名称已存在");
				}
			});
		});
	});
	$(function(){
		$("#submitBtn").click(function() {
			$.post("${basePath}/product/addProduct", $("#addProductForm").serialize(), function(data) {
				if (data.success) {
					window.location.href="/home";
				} else {
					alert(data.msg)
				}
			});
		});
	});
	$(function() {
		$("#clearBtn").click(function() {
			// 清空文本框
			$("#clearDiv").find('input[type="text"]').each(function() {
				$(this).val("");
			});
			$("#productDesc").val("");
		});
		
		$("#cancelBtn").click(function() {
			window.location.href="${basePath}/product/toAddProduct";
		});
	});
</script>
</head>
<form id="addProductForm" name="addProductForm" enctype="multipart/form-data" class="form-horizontal" role="form">
	<div id="clearDiv" class="container">
		<div class="row clearfix">
			<div class="col-md-12 column" style="padding-top:10px">
				<div class="form-group">
					<label for="productName" class="col-sm-2 control-label">产品名称：</label>
					<div class="col-sm-10">
						<input style="width:20%;padding-left: 3px; padding-right: 5px; padding-top: 4px;" class="form-control" id="productName" name="productName" type="text" />
					</div>
				</div>
				<div class="form-group">
					<label for="developer" class="col-sm-2 control-label">产品开发负责人：</label>
					<div class="col-sm-10">
						<input style="width:20%;padding-left: 3px; padding-right: 5px; padding-top: 4px;" class="form-control" id="developer" name="developer" type="text" />
					</div>
				</div>
				<div class="form-group">
					<label for="productManager" class="col-sm-2 control-label">产品经理：</label>
					<div class="col-sm-10">
						<input style="width:20%;padding-left: 3px; padding-right: 5px; padding-top: 4px;" class="form-control" id="productManager" name="productManager" type="text" />
					</div>
				</div>
				<div class="form-group">
					<label for="operationsStaff" class="col-sm-2 control-label">产品运维负责人：</label>
					<div class="col-sm-10">
						<input style="width:20%;padding-left: 3px; padding-right: 5px; padding-top: 4px;" class="form-control" id="operationsStaff" name="operationsStaff" type="text" />
					</div>
				</div>
				<div class="form-group">
					<label for="productDesc" class="col-sm-2 control-label">产品说明：</label>
					<div class="col-md-10 column">
						<textarea id="productDesc" name="productDesc" style="width: 70%; height: 100px;"></textarea>
					</div>
				</div>
			</div>
			<div class="col-md-8 column">
				<div align="center" class="form-group">
					<button id="submitBtn" type="button" class="btn btn-default">确定</button>
					<button id="cancelBtn" type="button" class="btn btn-default">取消</button>
					<button id="clearBtn" type="button" class="btn btn-default">重置</button>
				</div>
			</div>
		</div>
	</div>
</form>